import React, { Component } from "react";
import { withRouter} from 'react-router-dom'
import { Layout, Menu,  } from "antd";
import {
  UserOutlined,
  LaptopOutlined,
  NotificationOutlined,
  TeamOutlined ,
} from "@ant-design/icons";

const { SubMenu } = Menu;
const {  Sider } = Layout;




class MySider extends Component {

    skip=(params) => {
        // console.log(params)
        // console.log(this.props.location.pathname)
        const [path,subMenuKey] = params.keyPath;
        if (subMenuKey) {
            localStorage.setItem('subMenuKey',subMenuKey)
        }else {
            localStorage.removeItem('subMenuKey')
        }
        this.props.history.push(path);
    }

    render() {
        return (
            <Sider width={200} className="site-layout-background">
              <Menu
                mode="inline"
                defaultSelectedKeys={[this.props.location.pathname]}
                defaultOpenKeys={[localStorage.getItem('subMenuKey')]}
                style={{  height: '100%', borderRight: 0 }}
                onClick={ this.skip }
              >             
                  <Menu.Item key="/nav/home">首页</Menu.Item>                 
                  <Menu.Item key="/nav/order">订单管理</Menu.Item>
                <SubMenu
                  key="sub1"
                  icon={<NotificationOutlined />}
                  title="产品管理"
                >
                  <Menu.Item key="/nav/shopList">活期</Menu.Item>
                  <Menu.Item key="/nav/shopAdd">定期</Menu.Item>
                  <Menu.Item key="/nav/shopAdd">基金</Menu.Item>
                  <Menu.Item key="/nav/shopAdd">黄金</Menu.Item>
                </SubMenu>

                <SubMenu
                  key="sub2"
                  icon={<TeamOutlined />}
                  title="用户管理"
                >
                  <Menu.Item key="/nav/accountList"> 用户列表</Menu.Item>
                  <Menu.Item key="/nav/accountAdd">添加用户</Menu.Item>
                </SubMenu>

                {/* <SubMenu
                  key="sub3"
                  icon={<UserOutlined />}
                  title="商品管理"
                >
                  <Menu.Item key="commodityList">商品列表</Menu.Item>
                  <Menu.Item key="commodityAdd">添加商品</Menu.Item>
                </SubMenu> */}

                {/* <SubMenu
                  key="sub4"
                  icon={<LaptopOutlined />}
                  title="销售统计"
                >
                  <Menu.Item key="orderStatistics">订单统计</Menu.Item>
                  <Menu.Item key="commodityStatistics">商品统计</Menu.Item>
                </SubMenu> */}


              </Menu>
            </Sider>
        )
    }
}

export default withRouter(MySider);